CC = arm-none-linux-gnueabi-g++
INCLUDE = $(shell pkg-config --cflags arm-opencv)
#INCLUDE += -I/develop/zxing_arm/zxing/cpp/core/src -I/usr/local/arm/libiconv_lib/include
LIBS_OPENCV=$(shell pkg-config --libs arm-opencv)
CFLAGS += -ansi -pedantic -O0 -g3 -ggdb -Wall -Wextra -Werror
LDFLAGS += -pthread
LIBS += -ldl -L/usr/lib -L/opt/local/lib -L/usr/local/lib -L/usr/local/arm/libiconv_lib/lib/ 
START_LIB = /develop/zxing_arm/zxing/cpp/build/libzxing.a
OPENCV_STATIC_LIB = /usr/local/arm/opencv_lib_static/lib/*.a
OPENCV_STATIC_INC = /usr/local/arm/opencv_lib_static/include/
EXEC=zxing
OBJS= lodepng.o ImageReaderSource.o jpgd.o main.o camera_device.o lcd_display.o serial.o beep.o led.o fb_device.o v4l_device.o jpegenc.o
$(EXEC): $(OBJS)
#	$(CC) $(CFLAGS) $(LDFAGS) $(INCLUDE) -o $(EXEC)  $(LIBS) $(OBJS) $(START_LIB) $(LIBS_OPENCV) -liconv
	arm-none-linux-gnueabi-g++ -Wno-long-long -o zxing   -ldl -L/usr/lib -L/opt/local/lib -L/usr/local/lib -L/develop/zxing_arm/libiconv/lib $(INCLUDE) \
	ImageReaderSource.o jpgd.o lodepng.o camera_device.o lcd_display.o serial.o beep.o led.o fb_device.o \
	v4l_device.o main.o /develop/zxing_arm/zxing/cpp/build/libzxing.a -liconv $(LIBS_OPENCV)
	
	cp zxing /develop/s5pv210/s5pv210_demo/buildroot-2013.02/board/wit/wit_210/rootfs-overlay/bin
	cp zxing /nfsroot/rootfs/
led.o: led.cpp led.h
	arm-none-linux-gnueabi-g++ -o led.o -c -ansi -pedantic -O0 -g3 -ggdb -Wall -Wextra -Werror -Wno-long-long led.cpp
beep.o: beep.cpp beep.h	
	arm-none-linux-gnueabi-g++ -o beep.o -c -ansi -pedantic -O0 -g3 -ggdb -Wall -Wextra -Werror -Wno-long-long beep.cpp
serial.o: serial.cpp serial.h	
	arm-none-linux-gnueabi-g++ -o serial.o -c -ansi -pedantic -O0 -g3 -ggdb -Wall -Wextra -Werror -Wno-long-long serial.cpp
lcd_display.o: lcd_display.cpp lcd_display.h
	arm-none-linux-gnueabi-g++ -o lcd_display.o -c -ansi -pedantic -O0 -g3 -ggdb -Wall -Wextra -Werror -Wno-long-long lcd_display.cpp
fb_device.o: ./camera_v4l/fb_device.cpp
	arm-none-linux-gnueabi-g++ -o $@ -c -ansi -pedantic -O0 -g3 -ggdb  -Wno-long-long $<
v4l_device.o: ./camera_v4l/v4l_device.cpp
	arm-none-linux-gnueabi-g++ -o $@ -c -ansi -pedantic -O0 -g3 -ggdb  -Wno-long-long $<
jpegenc.o:./camera_v4l/jpegenc.cpp
		arm-none-linux-gnueabi-g++ -o $@ -c -ansi -pedantic -O0 -g3 -ggdb  -Wno-long-long $<

camera_device.o:camera_device.cpp camera_device.h
	arm-none-linux-gnueabi-g++ -o camera_device.o -c -ansi -pedantic -O0 -g3 -ggdb -Wall -Wextra -Werror -Wno-long-long camera_device.cpp
lodepng.o:lodepng.cpp lodepng.h
#	$(CC) $(CFLAGS) $(LDFAGS) -c lodepng.cpp -o lodepng.o
	arm-none-linux-gnueabi-g++ -o lodepng.o -c -ansi -pedantic -O0 -g3 -ggdb -Wall -Wextra -Werror -Wno-long-long -I/develop/zxing_arm/zxing/cpp/core/src lodepng.cpp
ImageReaderSource.o:ImageReaderSource.cpp ImageReaderSource.h
#	$(CC) $(CFLAGS) $(LDFAGS) $(INCLUDE) -c ImageReaderSource.cpp -o ImageReaderSource.o
	arm-none-linux-gnueabi-g++ -o ImageReaderSource.o -c -ansi -pedantic -O0 -g3 -ggdb -Wall -Wextra -Werror -Wno-long-long -I/develop/zxing_arm/zxing/cpp/core/src ImageReaderSource.cpp
jpgd.o:jpgd.cpp jpgd.h
#	$(CC) $(CFLAGS) $(LDFAGS) $(INCLUDE) -c jpgd.cpp -o jpgd.o
	arm-none-linux-gnueabi-g++ -o jpgd.o -c -ansi -pedantic -O0 -g3 -ggdb -Wall -Wextra -Werror -Wno-long-long -I/develop/zxing_arm/zxing/cpp/core/src jpgd.cpp
main.o:main.cpp
#	$(CC) $(CFLAGS) $(LDFAGS) $(INCLUDE) -c main.cpp -o main.o
	arm-none-linux-gnueabi-g++ -o main.o -static -c -ansi -pedantic -O0 -g3 -ggdb -Wall -Wextra -Werror -Wno-long-long -I/develop/zxing_arm/zxing/cpp/core/src $(INCLUDE) main.cpp
	
clean:
	-rm -f $(EXEC) *.o *~ *.out ./camera_v4l/*.o
.PHONY: clean

